package com.example.microinvestweb.controller.admin;
import com.example.microinvestcommon.entity.BuyStock;
import com.example.microinvestcommon.entity.SellStock;
import com.example.microinvestcommon.entity.Users;
import com.example.microinvestcommon.pojo.Result;
import com.example.microinvestcommon.vo.BuyStockVo;
import com.example.microinvestcommon.vo.SellStockVo;
import com.example.microinvestcommon.vo.UsersVo;
import com.example.microinvestuser.service.admin.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin")
public class AdminController {
    private final AdminService adminService;

    @Autowired
    public AdminController(AdminService adminService){
        this.adminService=adminService;
    }


    //管理员登录
    @PostMapping("/loginWithAdminNamePassword")
    public Result<String> loginWithAdminNamePassword(String AdminName, String password){
        //由前端判断输入是否为空
        Result result=adminService.loginWithAdminNamePasswordService(AdminName,password);
        return result;
    }

    //获取用户信息
    @GetMapping("/getUsersMessage")
    public Result<List<UsersVo>> getUsersMessage(){
        Result<List<UsersVo>> result= adminService.getUsersMessageService();
        return result;
    }

    //获取购买股票信息
    @GetMapping("/getBuyStockMessage")
    public Result<List<BuyStockVo>> getBuyStockMessage(){
        Result<List<BuyStockVo>> result= adminService.getBuyStockMessage();
        return result;
    }

    //获取卖出股票信息
    @GetMapping("/getSellStockMessage")
    public Result<List<SellStockVo>> getSellStockMessage(){
        Result<List<SellStockVo>> result= adminService.getSellStockMessage();
        return result;
    }

    //删除股票信息
    @DeleteMapping("/deleteStockMessage")
    public Result<String> deleteStockMessage(@RequestBody List<String> stockSymbols){
        Result<String> result=adminService.deleteStockMessage(stockSymbols);
        return result;
    }
}
